<?php
require_once(dirname(__FILE__) . '/PortalUtil.class.php');

class Token extends PortalUtil {
	public $tbl = Constant::tbl_wifi_token;

	function __construct() {
		$request['update'] = '$Date: 2009/02/16 07:36:07 $';
		$request['revision'] = '$Revision: 1.1 $';

		parent::__construct($request);
	}

	/**
	 *
	 *
	 * @param Controler $controller
	 * @param array $request
	 */
	function layout($controller, $request) {
		
		$url = $_SESSION['url'];

		$controller->display($request, 'wlan/index');
		
		// redirect('http://www.baidu.com', 'location', 302);
		
		return true;
	}
	
	function _insert($request) {
		$username = $request['username'];
		$password = $request['password'];
		
		$gw_ip = $request['gw_address'];
		$gw_port = $request['gw_port'];
		
		$gw_id = $request['gw_id'];
		$mac = $request['mac'];
		
		$token = $request['token'];
		
		$db = newdb($this->dsn_w);
		$fmt = "INSERT INTO %s(username, token, gw_ip, gw_port, gw_id, mac, createtime)";
		$fmt .= " VALUES('%s', '%s', '%s', '%s', '%s', '%s', NOW(), NOW())";
		$sql = sprintf($fmt, $this->tbl, $username, $token, $gw_ip, $gw_port, $gw_id, $mac);
		debug($sql);
		$db->query($sql);
	}
}
?>
